package oli.plugmgr.core
{
	import de.polygonal.ds.SLinkedList;
	
	import flash.events.EventDispatcher;
	
	import oli.plugmgr.events.PlugRegEvent;
	import oli.plugpack.core.PlugIn;
	
	
	public final class PlugRegistry extends EventDispatcher
	{
		private var _registry:Vector.<PlugIn>;
		private var pe:PlugRegEvent;
		private var _idList:SLinkedList;
		private var _versionList:SLinkedList;
		
		public function PlugRegistry()
		{
			
			super(null);
			
			_registry = new Vector.<PlugIn>();
			_idList = new SLinkedList();
			_versionList = new SLinkedList();
			
			pe = new PlugRegEvent(PlugRegEvent.PLUGREG);
			
		}

		public function get versionList():SLinkedList
		{
			return _versionList;
		}

		public function get registry():Vector.<PlugIn>
		{
			return _registry;
		}
		public function get idList():SLinkedList
		{
			return _idList;
		}

		public function registerPlugIn(p:PlugIn):void
		{
			_registry.push(p);
			_idList.append(p.id);
			_versionList.append(p.version);
			pe.plugin = p;
			dispatchEvent(pe);
			//trace("inside registerPLugIn");
		}
		// TODO unregisterPlugIn()
	}
}